import Vue from 'vue'
import App from './App.vue'
import router from './router'
import './plugins/element.js'
// 导入字体图标
import './assets/fonts/iconfont.css'
// 导入全局样式表
import './assets/css/global.css'

import NProgress from 'nprogress'
import 'nprogress/nprogress.css'

import VueQuillEditor from 'vue-quill-editor'
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'
Vue.use(VueQuillEditor);

import AMap from 'vue-amap';
Vue.use(AMap);

import ECharts from 'vue-echarts/components/ECharts.vue'

//引入所有表 
require("echarts");
 
// 手动引入 ECharts 各模块来减小打包体积，建议
import 'echarts/lib/chart/bar'
import 'echarts/lib/chart/pie'
import 'echarts/lib/chart/line'
import 'echarts/lib/component/tooltip'
import 'echarts/lib/component/polar'
import 'echarts/lib/component/legend'
import 'echarts/lib/component/title.js'
 
// 注册组件以便在项目中引用
Vue.component('charts', ECharts);

import axios from 'axios'
// 服务器地址配置 
axios.defaults.baseURL = 'http://webproxy2.jxhonline.com:20260/api/'
//axios.defaults.baseURL = 'http://localhost:20260/api/'

axios.interceptors.request.use(config => {
  NProgress.start()
  config.headers.token = window.sessionStorage.getItem('token')
  return config
})

axios.interceptors.response.use(config => {
  NProgress.done()
  return config
})

Vue.prototype.$http = axios

Vue.filter('dateFormat', function (originVal) {
  if(!originVal) return ''
  const dt = new Date(originVal)
  const y = dt.getFullYear()
  const m = (dt.getMonth() + 1 + '').padStart(2, '0')
  const d = (dt.getDate() + '').padStart(2, '0')

  const hh = (dt.getHours() + '').padStart(2, '0')
  const mm = (dt.getMinutes() + '').padStart(2, '0')
  const ss = (dt.getSeconds() + '').padStart(2, '0')
  return `${y}-${m}-${d} ${hh}:${mm}:${ss}`
})

Vue.filter('dateFormatNoTime', function (originVal) {
  const dt = new Date(originVal)
  const y = dt.getFullYear()
  const m = (dt.getMonth() + 1 + '').padStart(2, '0')
  const d = (dt.getDate() + '').padStart(2, '0')
  return `${y}-${m}-${d}`
})

Vue.filter('sexFormat', function (sex) {
  if (sex === 1) return '男'
  return '女'
})

Vue.config.productionTip = false



new Vue({
  router,
  render: h => h(App)
}).$mount('#app')

AMap.initAMapApiLoader({
  // 高德key
  key: '6fb0d312349708aabc14ad967930ce9e',
  // 插件集合 （插件按需引入）
  plugin: [

    "AMap.Autocomplete", 
    //输入提示插件
  
    "AMap.PlaceSearch", 
    //POI搜索插件
 
    "AMap.Scale", 
    //右下角缩略图插件 比例尺
  
    "AMap.OverView", 
    //地图鹰眼插件
   
    "AMap.ToolBar", 
    //地图工具条
   
    "AMap.MapType", 
    //类别切换控件，实现默认图层与卫星图、实施交通图层之间切换的控制
   
     "AMap.PolyEditor", 
    //编辑 折线多，边形
   
    "AMap.CircleEditor", 
    //圆形编辑器插件
   
    "AMap.Geolocation",
    //定位控件，用来获取和展示用户主机所在的经纬度位置
    'MarkerClusterer',

    "AMap.Heatmap"

     ],
 // zoom: 13
});
